import request from '@/config/axios'

/** 学习经历条目 */
export interface RecruitInterviewStudyItem {
  startDate?: string
  endDate?: string
  school?: string
  major?: string
  post?: string
  graduation?: string
}

/** 工作经历条目 */
export interface RecruitInterviewWorkItem {
  startDate?: string
  endDate?: string
  company?: string
  post?: string
  certifier?: string
  phone?: string
  description?: string
}

/** 家庭成员条目 */
export interface RecruitInterviewFamilyItem {
  name?: string
  relation?: string
  age?: string | number
  company?: string
  post?: string
  phone?: string
  remark?: string
}

/** 面试信息 */
export interface RecruitInterview {
  id?: number
  interviewTime?: string
  trailResult?: string
  interviewResult?: string
  post?: string
  channels?: string
  inviter?: string
  date?: string
  name?: string
  sex?: string
  dateOfBirth?: string
  nation?: string
  education?: string
  graduateInstitutions?: string
  major?: string
  height?: number
  healthCondition?: string
  marriageState?: string
  cardId?: string
  urgentPhone?: string
  politicalOutlook?: string
  currentAddress?: string
  address?: string
  emergencyContact?: string
  relation?: string
  emergencyContactPhone?: string
  leaveCause?: string
  lastSalary?: string
  expectedSalary?: string
  arrivalTime?: string
  preliminaryUser?: string
  reexamineUser?: string
  whetherToHire?: string
  noHireCause?: string
  agreeDate?: string
  remark?: string
  /** 0:待登记 1:待面试 2:面试不通过 3:待入职 4:未入职 5:已入职 6:未登记 */
  status?: string
  workList?: string
  studyList?: string
  familyList?: string
  userId?: string
  dingUserId?: string
  createTime?: string
}

// 面试 API
export const RecruitInterviewApi = {
  /** 查询面试分页 */
  getRecruitInterviewPage: async (params: any) => {
    return await request.get({ url: `/hr/recruit-interview/page`, params })
  },

  /** 查询面试详情 */
  getRecruitInterview: async (id: number) => {
    return await request.get({ url: `/hr/recruit-interview/get?id=` + id })
  },

  /** 新增面试 */
  createRecruitInterview: async (data: RecruitInterview) => {
    return await request.post({ url: `/hr/recruit-interview/create`, data })
  },

  /** 修改面试 */
  updateRecruitInterview: async (data: RecruitInterview) => {
    return await request.put({ url: `/hr/recruit-interview/update`, data })
  },

  /** 面试结果 */
  recruitInterviewResult: async (data: RecruitInterview) => {
    return await request.put({ url: `/hr/recruit-interview/interview-result`, data })
  },

  /** 删除面试 */
  deleteRecruitInterview: async (id: number) => {
    return await request.delete({ url: `/hr/recruit-interview/delete?id=` + id })
  },

  /** 批量删除面试 */
  deleteRecruitInterviewList: async (ids: number[]) => {
    return await request.delete({ url: `/hr/recruit-interview/delete-list?ids=${ids.join(',')}` })
  },

  /** 导出面试 Excel */
  exportRecruitInterview: async (params: any) => {
    return await request.download({ url: `/hr/recruit-interview/export-excel`, params })
  }
}
